package javafx.FX3Ddemo;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Camera;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.SubScene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Sphere;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;

public class FX3DTest extends Application{
	private int width = 50;
	private int height = 50;
	private int depth = 50;
	
	private int radius = 25;
	private int divisions = 50;
	

	public void start(Stage stage) throws Exception {
		
		PhongMaterial redMaterial = new PhongMaterial();
		redMaterial.setSpecularColor(Color.ORANGE);
		redMaterial.setDiffuseColor(Color.RED);
		
		PhongMaterial blueMaterial = new PhongMaterial();
		blueMaterial.setDiffuseColor(Color.BLUE);
		blueMaterial.setSpecularColor(Color.LIGHTBLUE);

		PhongMaterial greyMaterial = new PhongMaterial();
		greyMaterial.setDiffuseColor(Color.DARKGREY);
		greyMaterial.setSpecularColor(Color.GREY);
		
		
		/*****************************************************/
		
		Box myBox = new Box(width, height, depth);
		myBox.setMaterial(redMaterial);
		
		Cylinder myCylinder = new Cylinder(radius, height);
		myCylinder.setMaterial(blueMaterial);
		
		Sphere mySphere = new Sphere(radius, divisions);
		mySphere.setMaterial(greyMaterial);
		
		HBox hBox = new HBox();
		hBox.setPadding(new Insets(50));
		hBox.setSpacing(10);
		hBox.getChildren().addAll(myBox,myCylinder,mySphere);
		
		/*****************************************************/

		Camera pCamera = new PerspectiveCamera(true);
		
//        pCamera.getTransforms().addAll (
//                new Rotate(-20, Rotate.Y_AXIS),
//                new Rotate(-20, Rotate.X_AXIS),
//                new Translate(0, 0, -500));
 
        Group root = new Group();
        root.getChildren().add(pCamera);
        root.getChildren().add(hBox);

        SubScene subScene = new SubScene(root,400,300);
        subScene.setFill(Color.ALICEBLUE);
//        subScene.setCamera(pCamera);
		
        Group group = new Group();
        group.getChildren().add(subScene);
	    /*****************************************************/
		
		Scene scene = new Scene(group,500,300);
		stage.setScene(scene);
		stage.show();
	}
	
	public static void main(String[] args) {
		
		launch(null);
		
	}

}
